package com.referencing_array_ypes;

public class ReferencingArrayTypes {
    public static void main(String[] args) {
        //引用型数组
        Dog[] dogs = new Dog[4];
        Fish[] fish = new Fish[2];
        Chick[] chicks = new Chick[2];


        //添加数据
        dogs[0] = new Dog("小白", 1, "黑");
        dogs[1] = new Dog("小红", 2, "红");
        dogs[2] = new Dog("小灰", 1, "灰");
        dogs[3] = new Dog("小蓝", 3, "蓝");

        fish[0] = new Fish("小白鱼", 1, "白");
        fish[1] = new Fish("小金鱼", 2, "金");

        chicks[0] = new Chick("小黑鸡", 1, "黑");
        chicks[1] = new Chick("大黑鸡", 2, "黑");

        //去数据
        System.out.println(dogs[0].name);

        //遍历取出数据
        for (int i = 0; i < dogs.length; i++) {
            System.out.println("第" + (i+1) + "狗狗叫" + dogs[i].name + ",今年" + dogs[i].age + "岁了,是" + dogs[i].color + "色的");
        }
        System.out.println();

        for (int i = 0; i < fish.length; i++) {
            System.out.println("第" + (i+1) + "小鱼叫" + fish[i].name + ",今年" + fish[i].age + "岁了,是" + fish[i].color + "色的");
        }
        System.out.println();
        for (int i = 0; i < chicks.length; i++) {
            System.out.println("第" + (i+1) + "小鸡叫" + chicks[i].name + ",今年" + chicks[i].age + "岁了,是" + chicks[i].color + "色的");
        }
    }
}
